﻿namespace MicroCloud.Utils
{
    /// <summary>
    /// 区域语系
    /// </summary>
    public class Locale
    {
        /// <summary>
        /// 初始化一个区域语系 <see cref="Locale"/> 的新实例
        /// </summary>
        /// <param name="lanuage">语系</param>
        /// <param name="country">国家或区域</param>
        /// <param name="langType">语言类型</param>
        private Locale(string lanuage, string country, LangType langType)
        {
            Lanuage = lanuage;
            Country = country;
            LangType = langType;
        }

        #region 静态对象    
        /// <summary>
        /// ar_AE：阿拉伯语 Arabic
        /// </summary>
        public static readonly Locale AR_AE = new("ar", "AE", LangType.ar_AE);
 
        /// <summary>
        /// az_AZ：阿塞拜疆语 Azerbaijani
        /// </summary>
        public static readonly Locale AZ_AZ = new("az", "AZ", LangType.az_AZ);

        /// <summary>
        /// bg_BG：保加利亚语 Bulgarian
        /// </summary>
        public static readonly Locale BG_BG = new("bg", "BG", LangType.bg_BG);

        /// <summary>
        /// bn_BD：孟加拉语 Bengali
        /// </summary>
        public static readonly Locale BN_BD = new("bn", "BD", LangType.bn_BD);
 
        /// <summary>
        /// ca_CA：加泰罗尼亚语 Catalan
        /// </summary>
        public static readonly Locale CA_CA = new("ca", "CA", LangType.ca_CA);

        /// <summary>
        /// cs_CZ：捷克语 Czech
        /// </summary>
        public static readonly Locale CS_CZ = new("cs", "CZ", LangType.cs_CZ);

        /// <summary>
        /// cy_GB：威尔士语 Welsh
        /// </summary>
        public static readonly Locale CY_GB = new("cy", "GB", LangType.cy_GB);
    
        /// <summary>
        /// da_DK：丹麦语（丹麦）Danish (Denmark)
        /// </summary>
        public static readonly Locale DA_DK = new("da", "DK", LangType.da_DK);
   
        /// <summary>
        /// de_DE：德语 German
        /// </summary>
        public static readonly Locale DE_DE = new("de", "DE", LangType.de_DE);

        /// <summary>
        /// dv_DV：迪维希语 Dhivehi
        /// </summary>
        public static readonly Locale DV_DV = new("dv", "DV", LangType.dv_DV);

        /// <summary>
        /// el_GR：希腊语 Greek
        /// </summary>
        public static readonly Locale EL_GR = new("el", "GR", LangType.el_GR);

        /// <summary>
        /// en_US：英语（美国）English (United States)
        /// </summary>
        public static readonly Locale EN_US = new("en", "US", LangType.en_US);

        /// <summary>
        /// en_GB：英语（英国）English (United Kingdom)
        /// </summary>
        public static readonly Locale EN_GB = new("en", "GB", LangType.en_GB);

        /// <summary>
        /// es_ES：西班牙语 Spanish
        /// </summary>
        public static readonly Locale ES_ES = new("es", "ES", LangType.es_ES);

        /// <summary>
        /// et_EE：爱沙尼亚语 Estonian
        /// </summary>
        public static readonly Locale ET_EE = new("et", "EE", LangType.et_EE);

        /// <summary>
        /// eu_ES：巴斯克语 Basque
        /// </summary>
        public static readonly Locale EU_ES = new("eu", "ES", LangType.eu_ES);

        /// <summary>
        /// fa_IR：波斯语 Persian
        /// </summary>
        public static readonly Locale FA_IR = new("fa", "IR", LangType.fa_IR);

        /// <summary>
        /// fi_FI：芬兰语（芬兰）Finnish (Finland)
        /// </summary>
        public static readonly Locale FI_FI = new("fi", "FI", LangType.fi_FI);

        /// <summary>
        /// fr_FR：法语 French
        /// </summary>
        public static readonly Locale FR_FR = new("fr", "FR", LangType.fr_FR);

        /// <summary>
        /// ga_IE：爱尔兰语 Irish
        /// </summary>
        public static readonly Locale GA_IE = new("ga", "IE", LangType.ga_IE);

        /// <summary>
        /// gl_ES：加利西亚语 Galician
        /// </summary>
        public static readonly Locale GL_ES = new("gl", "ES", LangType.gl_ES);

        /// <summary>
        /// he_IL：希伯来语（以色列）Hebrew (Israel)
        /// </summary>
        public static readonly Locale HE_IL = new("he", "IL", LangType.he_IL);

        /// <summary>
        /// hi_IN：印地语 Hindi
        /// </summary>
        public static readonly Locale HI_IN = new("hi", "IN", LangType.hi_IN);

        /// <summary>
        /// hr_HR：克罗地亚语 Croatian
        /// </summary>
        public static readonly Locale HR_HR = new("hr", "HR", LangType.hr_HR);

        /// <summary>
        /// hu_HU：匈牙利语 Hungarian
        /// </summary>
        public static readonly Locale HU_HU = new("hu", "HU", LangType.hu_HU);

        /// <summary>
        /// hy_AM：亚美尼亚语 Armenian
        /// </summary>
        public static readonly Locale HY_AM = new("hy", "AM", LangType.hy_AM);

        /// <summary>
        /// id_ID：印度尼西亚语 Indonesian
        /// </summary>
        public static readonly Locale ID_ID = new("id", "ID", LangType.id_ID);

        /// <summary>
        /// is_IS：冰岛语 Icelandic
        /// </summary>
        public static readonly Locale IS_IS = new("is", "IS", LangType.is_IS);
    
        /// <summary>
        /// it_IT：意大利语 Italian
        /// </summary>
        public static readonly Locale IT_IT = new("it", "IT", LangType.it_IT);

        /// <summary>
        /// ja_JP：日语 Japanese
        /// </summary>
        public static readonly Locale JA_JP = new("ja", "JP", LangType.ja_JP);

        /// <summary>
        /// kab_DZ：卡拜尔语 Kabyle
        /// </summary>
        public static readonly Locale KAB_DZ = new("kab", "DZ", LangType.kab_DZ);
   
        /// <summary>
        /// kk_KZ：哈萨克语 Kazakh
        /// </summary>
        public static readonly Locale KK_KZ = new("kk", "KZ", LangType.kk_KZ);
       
        /// <summary>
        /// ko_KR：朝鲜语（南韩）Korean
        /// </summary>
        public static readonly Locale KO_KR = new("ko", "KR", LangType.ko_KR);

        /// <summary>
        /// ckb_IR：库尔德语 Kurdish
        /// </summary>
        public static readonly Locale CKB_IR = new("ckb", "IR", LangType.ckb_IR);
 
        /// <summary>
        /// lt_LT：立陶宛语 Lithuanian
        /// </summary>
        public static readonly Locale LT_LT = new("lt", "LT", LangType.lt_LT);
 
        /// <summary>
        /// lv_LV：拉脱维亚语 Latvian
        /// </summary>
        public static readonly Locale LV_LV = new("lv", "LV", LangType.lv_LV);

        /// <summary>
        /// nb_NB：挪威博克马尔语 Norwegian Bokmal
        /// </summary>
        public static readonly Locale NB_NB = new("nb", "NB", LangType.nb_NB);
   
        /// <summary>
        /// nb_NO：挪威语（挪威）Norwegian (Norway)
        /// </summary>
        public static readonly Locale NB_NO = new("nb", "NO", LangType.nb_NO);

        /// <summary>
        /// ne_NP：尼泊尔语 Nepali
        /// </summary>
        public static readonly Locale NE_NP = new("ne", "NP", LangType.ne_NP);
     
        /// <summary>
        /// nl_NL：荷兰语（荷兰）Dutch (Netherlands)
        /// </summary>
        public static readonly Locale NL_NL = new("nl", "NL", LangType.nl_NL);
    
        /// <summary>
        /// nl_BE：荷兰语（比利时）Dutch (Belgium)
        /// </summary>
        public static readonly Locale NL_BE = new("nl", "BE", LangType.nl_BE);

        /// <summary>
        /// oc_OC：奥克语 Occitan
        /// </summary>
        public static readonly Locale OC_OC = new("oc", "OC", LangType.oc_OC);

        /// <summary>
        /// pl_PL：波兰语 Polish
        /// </summary>
        public static readonly Locale PL_PL = new("pl", "PL", LangType.pl_PL);

        /// <summary>
        /// pt_PT：葡萄牙语 Portuguese
        /// </summary>
        public static readonly Locale PT_PT = new("pt", "PT", LangType.pt_PT);
  
        /// <summary>
        /// pt_BR：葡萄牙语（巴西）Portuguese (Brazil)
        /// </summary>
        public static readonly Locale PT_BR = new("pt", "BR", LangType.pt_BR);

        /// <summary>
        /// ro_RO：罗马尼亚语 Romanian
        /// </summary>
        public static readonly Locale RO_RO = new("ro", "RO", LangType.ro_RO);
  
        /// <summary>
        /// ru_RU：俄语 Russian
        /// </summary>
        public static readonly Locale RU_RU = new("ru", "RU", LangType.ru_RU);
 
        /// <summary>
        /// sk_SK：斯洛伐克语 Slovak
        /// </summary>
        public static readonly Locale SK_SK = new("sk", "SK", LangType.sk_SK);

        /// <summary>
        /// sl_SL：斯洛文尼亚语 Slovenian
        /// </summary>
        public static readonly Locale SL_SL = new("sl", "SL", LangType.sl_SL);
  
        /// <summary>
        /// sq_AL：阿尔巴尼亚语 Albanian
        /// </summary>
        public static readonly Locale SQ_AL = new("sq", "AL", LangType.sq_AL);

        /// <summary>
        /// sr_cyrl_RS：塞尔维亚语（西里尔文） Serbian
        /// </summary>
        public static readonly Locale SR_CYRL_RS = new("sr-cyrl", "RS", LangType.sr_cyrl_RS);

        /// <summary>
        /// sv_SE：瑞典语 Swedish
        /// </summary>
        public static readonly Locale SV_SE = new("sv", "SE", LangType.sv_SE);

        /// <summary>
        /// ta_IN：泰米尔语 Tamil
        /// </summary>
        public static readonly Locale TA_IN = new("ta", "IN", LangType.ta_IN);
 
        /// <summary>
        /// tg_TJ：塔吉克语 Tajik
        /// </summary>
        public static readonly Locale TG_TJ = new("tg", "TJ", LangType.tg_TJ);

        /// <summary>
        /// th_TH：泰语 Thai
        /// </summary>
        public static readonly Locale TH_TH = new("th", "TH", LangType.th_TH);

        /// <summary>
        /// tr_TR：土耳其语 Turkish
        /// </summary>
        public static readonly Locale TR_TR = new("tr", "TR", LangType.tr_TR);

        /// <summary>
        /// ug_CN：维吾尔语 Uyghur
        /// </summary>
        public static readonly Locale UG_CN = new("ug", "CN", LangType.ug_CN);

        /// <summary>
        /// uk_UK：乌克兰语 Ukrainian
        /// </summary>
        public static readonly Locale UK_UK = new("uk", "UK", LangType.uk_UK);

        /// <summary>
        /// vi_VN：越南语 Vietnamese
        /// </summary>
        public static readonly Locale VI_VN = new("vi", "VN", LangType.vi_VN);

        /// <summary>
        /// zh_CN：简体中文 Chinese
        /// </summary>
        public static readonly Locale ZH_CN = new("zh", "CN", LangType.zh_CN);

        /// <summary>
        /// zh_TW：繁体中文（台湾）Traditional Chinese (Tai Wan)
        /// </summary>
        public static readonly Locale ZH_TW = new("zh", "TW", LangType.zh_TW);

        /// <summary>
        /// 获取 语系设定
        /// </summary>
        public static Locale[] Locales
        {
            get
            {
                return new[]
                {
                    AR_AE, // 阿拉伯语 Arabic
                    AZ_AZ, // 阿塞拜疆语 Azerbaijani
                    BG_BG, // 保加利亚语 Bulgarian
                    BN_BD, // 孟加拉语 Bengali
                    CA_CA, // 加泰罗尼亚语 Catalan
                    CS_CZ, // 捷克语 Czech
                    CY_GB, // 威尔士语 Welsh
                    DA_DK, // 丹麦语（丹麦）Danish (Denmark)
                    DE_DE, // 德语 German
                    DV_DV, // 迪维希语 Dhivehi
                    EL_GR, // 希腊语 Greek
                    EN_US, // 英语（美国）English (United States)
                    EN_GB, // 英语（英国）English (United Kingdom)
                    ES_ES, // 西班牙语 Spanish
                    ET_EE, // 爱沙尼亚语 Estonian
                    EU_ES, // 巴斯克语 Basque
                    FA_IR, // 波斯语 Persian
                    FI_FI, // 芬兰语（芬兰）Finnish (Finland)
                    FR_FR, // 法语 French
                    GA_IE, // 爱尔兰语 Irish
                    GL_ES, // 加利西亚语 Galician
                    HE_IL, // 希伯来语（以色列）Hebrew (Israel)
                    HI_IN, // 印地语 Hindi
                    HR_HR, // 克罗地亚语 Croatian
                    HU_HU, // 匈牙利语 Hungarian
                    HY_AM, // 亚美尼亚语 Armenian
                    ID_ID, // 印度尼西亚语 Indonesian
                    IS_IS, // 冰岛语 Icelandic
                    IT_IT, // 意大利语 Italian
                    JA_JP, // 日语 Japanese
                    KAB_DZ, // 卡拜尔语 Kabyle
                    KK_KZ, // 哈萨克语 Kazakh
                    KO_KR, // 朝鲜语（南韩）Korean
                    CKB_IR, // 库尔德语 Kurdish
                    LT_LT, // 立陶宛语 Lithuanian
                    LV_LV, // 拉脱维亚语 Latvian
                    NB_NB, // 挪威博克马尔语 Norwegian Bokmal
                    NB_NO, // 挪威语（挪威）Norwegian (Norway)
                    NE_NP, // 尼泊尔语 Nepali
                    NL_NL, // 荷兰语（荷兰）Dutch (Netherlands)
                    NL_BE, // 荷兰语（比利时）Dutch (Belgium)
                    OC_OC, // 奥克语 Occitan
                    PL_PL, // 波兰语 Polish
                    PT_PT, // 葡萄牙语 Portuguese
                    PT_BR, // 葡萄牙语（巴西）Portuguese (Brazil)
                    RO_RO, // 罗马尼亚语 Romanian
                    RU_RU, // 俄语 Russian
                    SK_SK, // 斯洛伐克语 Slovak
                    SL_SL, // 斯洛文尼亚语 Slovenian
                    SQ_AL, // 阿尔巴尼亚语 Albanian
                    SR_CYRL_RS, // 塞尔维亚语（西里尔文） Serbian
                    SV_SE, // 瑞典语 Swedish
                    TA_IN, // 泰米尔语 Tamil
                    TG_TJ, // 塔吉克语 Tajik
                    TH_TH, // 泰语 Thai
                    TR_TR, // 土耳其语 Turkish
                    UG_CN, // 维吾尔语 Uyghur
                    UK_UK, // 乌克兰语 Ukrainian
                    VI_VN, // 越南语 Vietnamese
                    ZH_CN, // 简体中文 Chinese
                    ZH_TW, // 繁体中文（台湾）Traditional Chinese (Tai Wan)
                };
            }
        }

        #endregion

        #region 属性
        /// <summary>
        /// 获取 语系
        /// </summary>
        public string Lanuage { get; }
        
        /// <summary>
        /// 获取 国家或区域
        /// </summary>
        public string Country { get; }
        
        /// <summary>
        /// 获取 语言类型
        /// </summary>
        public LangType LangType { get; }

        #endregion

        #region Override
        /// <summary>
        /// 返回当前对象的字符表示
        /// </summary>
        /// <param name="connector">连接符</param>
        /// <returns></returns>
        public string ToString(string connector = "-")
        {
            if (!Lanuage.IsMissing() && !Country.IsMissing())
            {
                return $"{Lanuage}{connector}{Country}";
            }
            if (!Country.IsMissing() && Lanuage.IsMissing())
            {
                return Country;
            }
            return Lanuage;
        }

        #endregion        
    }

}
